package com;

import com.web.AppConfig;
import com.web.WebServerFactory;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import javax.servlet.ServletRegistration;

//@ComponentScan("com")
public class Start {

    public static void main(String[] args) {
        /*
        实例化容器，开始扫描
         */
        AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
        context.register(AppConfig.class); //注册配置类
        context.refresh();

        WebServerFactory webServerFactory = context.getBean(WebServerFactory.class);
        try {
            webServerFactory.createServer();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        // Create and register the DispatcherServlet
//        DispatcherServlet servlet = new DispatcherServlet(context);
//        ServletRegistration.Dynamic registration = servletContext.addServlet("app", servlet);
//        registration.setLoadOnStartup(1);
//        registration.addMapping("/app/*");


    }

}
